tonal-range
tonal-range
is a collection of functions to create note ranges.
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-range
API Reference
- range(begin, end) ⇒
Array
Create a numeric range. As parameters, it accepts numbers or note names.
It can create ascending or descending ranges.
- fromPitchSet(coll, midi) ⇒
String
Given a collection of pitch classes and a midi number, return the note name
from the collection or null if not in the collection.
This function can be partially applied.
- noteRange(gen, start, end) ⇒
Array
Create a note range using a function that convert from midi number to
note names
Can be partially applied
- chromatic(start, end) ⇒
Array
Create a range of chromatic notes. The altered notes will use flats.
- cycleOfFifths(the, the, the) ⇒
Array
Create a range with a cycle of fifths
- scaleRange(notes, start, end) ⇒
Array
Create a scale range. Given a pitch set (a collection of pitch classes),
and a start and end it returns a note range.
range(begin, end) ⇒ Array
Create a numeric range. As parameters, it accepts numbers or note names.
It can create ascending or descending ranges.
Kind: global function
Returns: Array
- an array of numbers or empty array if not valid parameters
Param | Type | Description |
---|
begin | Pitch | String | Number | the beginning note or number |
end | Pitch | String | Number | the end note or number |
Example
import { range } from 'tonal-range'
range('C5', 'C4')
range(10, 5)
tonal.range('C2', 'C3')
fromPitchSet(coll, midi) ⇒ String
Given a collection of pitch classes and a midi number, return the note name
from the collection or null if not in the collection.
This function can be partially applied.
Kind: global function
Returns: String
- the note name or null if note in the pitch classes
Param | Type | Description |
---|
coll | Array | the pitch classes collection |
midi | Number | the midi number |
Example
var fromPitchSet = require('note-ranges').fromPitchSet
fromPitchSet('C D E', 60)
aMajor = fromPitchSet('A C# E')
[69, 70, 71, 72, 73].map(aMajor)
noteRange(gen, start, end) ⇒ Array
Create a note range using a function that convert from midi number to
note names
Can be partially applied
Kind: global function
Returns: Array
- an array of note names
Param | Type | Description |
---|
gen | function | the note name generator. Its a function with signature (Number) => (String) that receives a note midi number and returns a note name |
start | String | Pitch | Integer | the first note (or midi number) of the range |
end | String | Pitch | Integer | the last note (or midi number) of the range |
chromatic(start, end) ⇒ Array
Create a range of chromatic notes. The altered notes will use flats.
Kind: global function
Returns: Array
- an array of note names
Param | Type | Description |
---|
start | String | Pitch | Integer | the first note (or midi number) of the range |
end | String | Pitch | Integer | the last note (or midi number) of the range |
Example
tonal.chromatic('C2', 'E2')
cycleOfFifths(the, the, the) ⇒ Array
Create a range with a cycle of fifths
Kind: global function
Returns: Array
- a range of cycle of fifths
Param | Type | Description |
---|
the | Integer | first step from tonic |
the | Integer | last step from tonic (can be negative) |
the | String | Pitch | tonic |
Example
var range = require('tonal-ranges')
range.cycleOfFifths(0, 6, 'C')
scaleRange(notes, start, end) ⇒ Array
Create a scale range. Given a pitch set (a collection of pitch classes),
and a start and end it returns a note range.
Kind: global function
Returns: Array
- the scale range, an empty array if not valid source or
null if not valid start or end
Param | Type | Description |
---|
notes | String | Array | the collection of pitch sets |
start | String | the first note of the range |
end | String | the last note of the range |
Example
var range = require('tonal-ranges')
range.scale('C D E F G A B', 'C3', 'C2')